// 导入用户集合
const { Cart } = require('../../../model/cart');
// 引入分页模块
const pagination = require('mongoose-sex-page')
const { decodeToken } = require('../../../middleGuard/jwt')

module.exports = async (req, res) => {
  const { index, size } = req.query
  const query = {}
  query.user = decodeToken(req.headers.authorization).userId
  console.log(query.user)
  const list = await pagination(Cart).find(query).sort({_id: -1}).page(index).size(size).populate('goods').populate('business').populate('user').exec()
  res.json({
      data: list
  })
}